package com.yfp.operation.controller;


import com.yfp.common.core.domain.R;
import com.yfp.common.security.utils.SecurityUtils;
import com.yfp.operation.domain.MachineDO;
import com.yfp.operation.service.MachineService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/machine")
@Tag(name = "获取设备列表")
public class MachineController {

    @Autowired
    private MachineService machineService;


    /**
     * 获取设备列表
     */
    @GetMapping("/list")
    @Operation(summary = "获取设备列表", description = "设备管理页面使用")
    public R getMachineByUserId(){
        // 获取用户id
        Long userId = SecurityUtils.getUserId();
        List<MachineDO> machines = machineService.getMachineOperationByUserId(userId);
        return R.ok(machines);
    }

}
